Skip to contentSkip to conversation

Change in openvpn[master]: mroute: Remove unused mask argument of mroute_get_in*

Openvpn-devel In review flichtenheld (Code Review) 2 participants 6 messages Oct 27, 2025 – Oct 28, 2025 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1761570487000.I501bf780957a9c685eed5994a15de09c28efc3f0@...2715...

#1 lore raw

Attention is currently required from: plaisthos.

Hello plaisthos,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1309?usp=email

to review the following change.

Change subject: mroute: Remove unused mask argument of mroute_get_in*
......................................................................

mroute: Remove unused mask argument of mroute_get_in*

These are obsolete since the removal of pf feature. Avoids spurious conversion warnings.

Change-Id I501bf780957a9c685eed5994a15de09c28efc3f0

---
M src/openvpn/mroute.c

1 file changed, 9 insertions(+), 18 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/09/1309/1

src/openvpn/mroute.c +9 -18
index 88ea647..b50d48f 100644
@@ -103,17 +103,12 @@
     return true;
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversion"
-#endif
-
 static inline void
-mroute_get_in_addr_t(struct mroute_addr *ma, const in_addr_t src, unsigned int mask)
+mroute_get_in_addr_t(struct mroute_addr *ma, const in_addr_t src)
 {
     if (ma)
     {
-        ma->type = MR_ADDR_IPV4 | mask;
+        ma->type = MR_ADDR_IPV4;
         ma->netbits = 0;
         ma->len = 4;
         ma->v4.addr = src;
@@ -121,11 +116,11 @@
 }
 
 static inline void
-mroute_get_in6_addr(struct mroute_addr *ma, const struct in6_addr src, unsigned int mask)
+mroute_get_in6_addr(struct mroute_addr *ma, const struct in6_addr src)
 {
     if (ma)
     {
-        ma->type = MR_ADDR_IPV6 | mask;
+        ma->type = MR_ADDR_IPV6;
         ma->netbits = 0;
         ma->len = 16;
         ma->v6.addr = src;
@@ -161,8 +156,8 @@
                 {
                     const struct openvpn_iphdr *ip = (const struct openvpn_iphdr *)BPTR(buf);
 
-                    mroute_get_in_addr_t(src, ip->saddr, 0);
-                    mroute_get_in_addr_t(dest, ip->daddr, 0);
+                    mroute_get_in_addr_t(src, ip->saddr);
+                    mroute_get_in_addr_t(dest, ip->daddr);
 
                     /* multicast packet? */
                     if (mroute_is_mcast(ip->daddr))
@@ -192,8 +187,8 @@
                     gc_free(&gc);
 #endif
 
-                    mroute_get_in6_addr(src, ipv6->saddr, 0);
-                    mroute_get_in6_addr(dest, ipv6->daddr, 0);
+                    mroute_get_in6_addr(src, ipv6->saddr);
+                    mroute_get_in6_addr(dest, ipv6->daddr);
 
                     if (mroute_is_mcast_ipv6(ipv6->daddr))
                     {
@@ -342,7 +337,7 @@
             }
             else
             {
-                ma->v6.addr.s6_addr[byte--] &= (IPV4_NETMASK_HOST << bits_to_clear);
+                ma->v6.addr.s6_addr[byte--] &= (0xFF << bits_to_clear);
                 bits_to_clear = 0;
             }
         }
@@ -552,10 +547,6 @@
     }
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
 void
 mroute_helper_free(struct mroute_helper *mh)
 {

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1309?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I501bf780957a9c685eed5994a15de09c28efc3f0
Gerrit-Change-Number: 1309
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>

#2 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos.

cron2 has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1309?usp=email )

Change subject: mroute: Remove unused mask argument of mroute_get_in*
......................................................................

Patch Set 2: Code-Review+2

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1309?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I501bf780957a9c685eed5994a15de09c28efc3f0
Gerrit-Change-Number: 1309
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Tue, 28 Oct 2025 12:20:12 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes

#3 lore raw

PATCH v2 1/1 mroute: Remove unused mask argument of mroute_get_in*

In reply to a message not in the archive

From: Frank Lichtenheld <[email protected]...>

These are obsolete since the removal of pf feature. Avoids spurious conversion warnings.

Change-Id I501bf780957a9c685eed5994a15de09c28efc3f0

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1309
---

This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1309
This mail reflects revision 2 of this Change.

Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>

src/openvpn/mroute.c +9 -18
index 88ea647..b50d48f 100644
@@ -103,17 +103,12 @@
     return true;
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversion"
-#endif
-
 static inline void
-mroute_get_in_addr_t(struct mroute_addr *ma, const in_addr_t src, unsigned int mask)
+mroute_get_in_addr_t(struct mroute_addr *ma, const in_addr_t src)
 {
     if (ma)
     {
-        ma->type = MR_ADDR_IPV4 | mask;
+        ma->type = MR_ADDR_IPV4;
         ma->netbits = 0;
         ma->len = 4;
         ma->v4.addr = src;
@@ -121,11 +116,11 @@
 }
 
 static inline void
-mroute_get_in6_addr(struct mroute_addr *ma, const struct in6_addr src, unsigned int mask)
+mroute_get_in6_addr(struct mroute_addr *ma, const struct in6_addr src)
 {
     if (ma)
     {
-        ma->type = MR_ADDR_IPV6 | mask;
+        ma->type = MR_ADDR_IPV6;
         ma->netbits = 0;
         ma->len = 16;
         ma->v6.addr = src;
@@ -161,8 +156,8 @@
                 {
                     const struct openvpn_iphdr *ip = (const struct openvpn_iphdr *)BPTR(buf);
 
-                    mroute_get_in_addr_t(src, ip->saddr, 0);
-                    mroute_get_in_addr_t(dest, ip->daddr, 0);
+                    mroute_get_in_addr_t(src, ip->saddr);
+                    mroute_get_in_addr_t(dest, ip->daddr);
 
                     /* multicast packet? */
                     if (mroute_is_mcast(ip->daddr))
@@ -192,8 +187,8 @@
                     gc_free(&gc);
 #endif
 
-                    mroute_get_in6_addr(src, ipv6->saddr, 0);
-                    mroute_get_in6_addr(dest, ipv6->daddr, 0);
+                    mroute_get_in6_addr(src, ipv6->saddr);
+                    mroute_get_in6_addr(dest, ipv6->daddr);
 
                     if (mroute_is_mcast_ipv6(ipv6->daddr))
                     {
@@ -342,7 +337,7 @@
             }
             else
             {
-                ma->v6.addr.s6_addr[byte--] &= (IPV4_NETMASK_HOST << bits_to_clear);
+                ma->v6.addr.s6_addr[byte--] &= (0xFF << bits_to_clear);
                 bits_to_clear = 0;
             }
         }
@@ -552,10 +547,6 @@
     }
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
 void
 mroute_helper_free(struct mroute_helper *mh)
 {
#4 lore raw

[Openvpn-devel] [PATCH applied] Re: mroute: Remove unused mask argument of mroute_get_in*

The "mask" bit is trivial (I have wondered a few times what it is for, seems "for nothing" - out it goes!). The 0xff bit needed a bit more thinking, but indeed, since we're only masking single-bytes at a time here, and shift left, 0xffffff and 0xff is the same thing - and not using an IPv4 constant for IPv6 seems like a proper thing to do!

Your patch has been applied to the master branch.

commit 2ae18239c30d96a4d16bc75a0204c4895e6cbce3

Author: Frank Lichtenheld
Date:   Tue Oct 28 13:20:23 2025 +0100
     mroute: Remove unused mask argument of mroute_get_in*

     Signed-off-by: Frank Lichtenheld <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1309
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg33939.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#5 lore raw
In reply to a message not in the archive

cron2 has uploaded a new patch set (#3) to the change originally created by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1309?usp=email )

The following approvals got outdated and were removed:
Code-Review+2 by cron2

Change subject: mroute: Remove unused mask argument of mroute_get_in*
......................................................................

mroute: Remove unused mask argument of mroute_get_in*

These are obsolete since the removal of pf feature. Avoids spurious conversion warnings.

Change-Id I501bf780957a9c685eed5994a15de09c28efc3f0

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1309
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg33939.html

---
M src/openvpn/mroute.c

1 file changed, 9 insertions(+), 18 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/09/1309/3

src/openvpn/mroute.c +9 -18
index 88ea647..b50d48f 100644
@@ -103,17 +103,12 @@
     return true;
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversion"
-#endif
-
 static inline void
-mroute_get_in_addr_t(struct mroute_addr *ma, const in_addr_t src, unsigned int mask)
+mroute_get_in_addr_t(struct mroute_addr *ma, const in_addr_t src)
 {
     if (ma)
     {
-        ma->type = MR_ADDR_IPV4 | mask;
+        ma->type = MR_ADDR_IPV4;
         ma->netbits = 0;
         ma->len = 4;
         ma->v4.addr = src;
@@ -121,11 +116,11 @@
 }
 
 static inline void
-mroute_get_in6_addr(struct mroute_addr *ma, const struct in6_addr src, unsigned int mask)
+mroute_get_in6_addr(struct mroute_addr *ma, const struct in6_addr src)
 {
     if (ma)
     {
-        ma->type = MR_ADDR_IPV6 | mask;
+        ma->type = MR_ADDR_IPV6;
         ma->netbits = 0;
         ma->len = 16;
         ma->v6.addr = src;
@@ -161,8 +156,8 @@
                 {
                     const struct openvpn_iphdr *ip = (const struct openvpn_iphdr *)BPTR(buf);
 
-                    mroute_get_in_addr_t(src, ip->saddr, 0);
-                    mroute_get_in_addr_t(dest, ip->daddr, 0);
+                    mroute_get_in_addr_t(src, ip->saddr);
+                    mroute_get_in_addr_t(dest, ip->daddr);
 
                     /* multicast packet? */
                     if (mroute_is_mcast(ip->daddr))
@@ -192,8 +187,8 @@
                     gc_free(&gc);
 #endif
 
-                    mroute_get_in6_addr(src, ipv6->saddr, 0);
-                    mroute_get_in6_addr(dest, ipv6->daddr, 0);
+                    mroute_get_in6_addr(src, ipv6->saddr);
+                    mroute_get_in6_addr(dest, ipv6->daddr);
 
                     if (mroute_is_mcast_ipv6(ipv6->daddr))
                     {
@@ -342,7 +337,7 @@
             }
             else
             {
-                ma->v6.addr.s6_addr[byte--] &= (IPV4_NETMASK_HOST << bits_to_clear);
+                ma->v6.addr.s6_addr[byte--] &= (0xFF << bits_to_clear);
                 bits_to_clear = 0;
             }
         }
@@ -552,10 +547,6 @@
     }
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
 void
 mroute_helper_free(struct mroute_helper *mh)
 {

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1309?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I501bf780957a9c685eed5994a15de09c28efc3f0
Gerrit-Change-Number: 1309
Gerrit-PatchSet: 3
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>

#6 lore raw
In reply to a message not in the archive

cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1309?usp=email )

Change subject: mroute: Remove unused mask argument of mroute_get_in*
......................................................................

mroute: Remove unused mask argument of mroute_get_in*

These are obsolete since the removal of pf feature. Avoids spurious conversion warnings.

Change-Id I501bf780957a9c685eed5994a15de09c28efc3f0

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1309
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg33939.html

---
M src/openvpn/mroute.c

1 file changed, 9 insertions(+), 18 deletions(-)
src/openvpn/mroute.c +9 -18
index 88ea647..b50d48f 100644
@@ -103,17 +103,12 @@
     return true;
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wconversion"
-#endif
-
 static inline void
-mroute_get_in_addr_t(struct mroute_addr *ma, const in_addr_t src, unsigned int mask)
+mroute_get_in_addr_t(struct mroute_addr *ma, const in_addr_t src)
 {
     if (ma)
     {
-        ma->type = MR_ADDR_IPV4 | mask;
+        ma->type = MR_ADDR_IPV4;
         ma->netbits = 0;
         ma->len = 4;
         ma->v4.addr = src;
@@ -121,11 +116,11 @@
 }
 
 static inline void
-mroute_get_in6_addr(struct mroute_addr *ma, const struct in6_addr src, unsigned int mask)
+mroute_get_in6_addr(struct mroute_addr *ma, const struct in6_addr src)
 {
     if (ma)
     {
-        ma->type = MR_ADDR_IPV6 | mask;
+        ma->type = MR_ADDR_IPV6;
         ma->netbits = 0;
         ma->len = 16;
         ma->v6.addr = src;
@@ -161,8 +156,8 @@
                 {
                     const struct openvpn_iphdr *ip = (const struct openvpn_iphdr *)BPTR(buf);
 
-                    mroute_get_in_addr_t(src, ip->saddr, 0);
-                    mroute_get_in_addr_t(dest, ip->daddr, 0);
+                    mroute_get_in_addr_t(src, ip->saddr);
+                    mroute_get_in_addr_t(dest, ip->daddr);
 
                     /* multicast packet? */
                     if (mroute_is_mcast(ip->daddr))
@@ -192,8 +187,8 @@
                     gc_free(&gc);
 #endif
 
-                    mroute_get_in6_addr(src, ipv6->saddr, 0);
-                    mroute_get_in6_addr(dest, ipv6->daddr, 0);
+                    mroute_get_in6_addr(src, ipv6->saddr);
+                    mroute_get_in6_addr(dest, ipv6->daddr);
 
                     if (mroute_is_mcast_ipv6(ipv6->daddr))
                     {
@@ -342,7 +337,7 @@
             }
             else
             {
-                ma->v6.addr.s6_addr[byte--] &= (IPV4_NETMASK_HOST << bits_to_clear);
+                ma->v6.addr.s6_addr[byte--] &= (0xFF << bits_to_clear);
                 bits_to_clear = 0;
             }
         }
@@ -552,10 +547,6 @@
     }
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
 void
 mroute_helper_free(struct mroute_helper *mh)
 {

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1309?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I501bf780957a9c685eed5994a15de09c28efc3f0
Gerrit-Change-Number: 1309
Gerrit-PatchSet: 3
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>